# -*- coding:utf-8 -*-
from project.settings import CELERY_BROKER_URL, CELERY_REDIS_PASSWD, RedisInfo
from kombu import Queue, Exchange

BROKER_URL = CELERY_BROKER_URL
# CELERY_RESULT_BACKEND = "rpc://"
CELERY_RESULT_BACKEND = "redis://:%s@%s/2" % (CELERY_REDIS_PASSWD, RedisInfo["host"]) if CELERY_REDIS_PASSWD else \
    "redis://%s/2" % RedisInfo["host"]
# CELERY_IGNORE_RESULT = True
CELERY_RESULT_PERSISTENT = False
CELERY_TRACK_STARTED = True

CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_ENABLE_UTC = True

CELERYD_PREFETCH_MULTIPLIER = 10

default_exchange = Exchange('default', type='direct')     # fanout
cpubound_exchange = Exchange('cpubound', type='direct')   # fanout
youmengpush_exchange = Exchange('youmengpush', type='direct')   # fanout
# paperwork_exchange = Exchange('paperwork', type='direct')
# paperanalyzer_exchange = Exchange('paperanalyzer', type='direct')

CELERY_QUEUES = (
    Queue('default', default_exchange, routing_key='default'),
    Queue('cpubound', cpubound_exchange, routing_key='cpubound'),
    Queue('youmengpush', youmengpush_exchange, routing_key='youmengpush'),
    # Queue('paperwork', paperwork_exchange, routing_key='paperwork'),
    # Queue('paperanalyzer', paperanalyzer_exchange, routing_key='paperanalyzer'),
    # Queue('mam', Exchange('mam', type='direct'), routing_key='mam')
)

CELERY_DEFAULT_QUEUE = 'default'
CELERY_DEFAULT_EXCHANGE = 'default'
CELERY_DEFAULT_ROUTING_KEY = 'default'
